package org.dubnation.base.util;

import lombok.Data;

@Data
public class AjaxResult {
    private Boolean success;
    private Object data;
    private String msg;

    public AjaxResult() {
    }

    public AjaxResult(Boolean success, Object data, String msg) {
        this.success = success;
        this.data = data;
        this.msg = msg;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    private static AjaxResult ajaxResult = new AjaxResult();
    public static AjaxResult success() {
        //给AjaxResult对象赋值
        ajaxResult.success = true;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }

    public static AjaxResult success(Object obj) {
        AjaxResult ajaxResult = new AjaxResult();
        //给AjaxResult对象赋值
        ajaxResult.success = true;
        ajaxResult.msg = "操作成功";
        ajaxResult.data = obj;
        return ajaxResult;
    }

    public static AjaxResult error() {
        AjaxResult ajaxResult = new AjaxResult();
        //给AjaxResult对象赋值
        ajaxResult.success = false;
        ajaxResult.msg = "操作失败";
        return ajaxResult;
    }

    public static AjaxResult error(String mistake) {
        AjaxResult ajaxResult = new AjaxResult();
        //给AjaxResult对象赋值
        ajaxResult.success = false;
        ajaxResult.msg = mistake;
        return ajaxResult;
    }
}
